/* 
 * File:   HttpServer.h
 * Author: dev
 *
 * Created on 26 September, 2014, 7:43 PM
 */

#ifndef HTTPSERVER_H
#define	HTTPSERVER_H

#include <boost/shared_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/asio.hpp>

namespace HTTP_SERVER {
    
    class HttpServer : private boost::noncopyable {
        
    public:
        
        typedef boost::shared_ptr<HttpServer> Ptr ;
        typedef boost::shared_ptr<const HttpServer> ConstPtr ;
        
        HttpServer( int );
        
        void start() ; 
        
        void stop() ;
        
        bool isAlive() const ;
        
        const int & getServerPort() const { return serverPort_ ; }
        
    private:
        
        void doAccept(boost::system::error_code);
        
        int serverPort_ ;
        boost::asio::io_service ioService_ ;
        boost::asio::ip::tcp::socket serverSocket_ ;
        boost::asio::ip::tcp::acceptor acceptor_;
        std::vector<boost::asio::ip::tcp::endpoint> serverEndPoints_ ;
        
    };
    
    
};

#endif	/* HTTPSERVER_H */

